home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / etc / init.d / microcode.ctl < prev    next >
Encoding:
Text File  |  2009-10-07  |  2.1 KB  |  108 lines

  1. #!/bin/sh
  2.  
  3. # Fork from original (upstream) microcode_ctl.start,
  4. # to simplify the maintainability.
  5.  
  6. ### BEGIN INIT INFO
  7. # Provides:          microcode.ctl
  8. # Required-Start:    $local_fs
  9. # Required-Stop:     $local_fs
  10. # Should-Start:      $remote_fs
  11. # Should-Stop:       $remote_fs
  12. # Default-Start:     2 3 4 5
  13. # Default-Stop:      0 1 6
  14. # Short-Description: Load Intel microcode on CPU
  15. # Description:       Load Intel microcode on CPU, which corrige
  16. #                    some CPU errata.
  17. ### END INIT INFO
  18.  
  19.  
  20.  
  21. # Package in removed but not yet purget status.
  22. [ ! -x /usr/sbin/microcode_ctl ] && exit 0
  23.  
  24. # aborting on non-Intel processor
  25.  
  26. grep -qs GenuineIntel /proc/cpuinfo || exit 0
  27.  
  28.  
  29. # perform the update
  30. doit ()
  31. {
  32.  
  33. # microcode location
  34.  
  35. MICROCODE=/usr/share/misc/intel-microcode.dat
  36.  
  37. if [ ! -e "$MICROCODE" ] ; then
  38.     echo "$0: microcode not found in $MICROCODE"
  39.   
  40. fi
  41.  
  42.  
  43. # device name in LANANA
  44. DEVICE=/dev/cpu/microcode
  45. # device name in devfsd
  46. DEVICE2=/dev/misc/microcode
  47. # device name in some old versions of udev
  48. DEVICE3=/dev/microcode
  49.  
  50. # Lets just be sure we have a device file...
  51. # ... with workaround because different name policy in lanana and devfsd
  52. if [ -x /sbin/modprobe ] ; then
  53.     /sbin/modprobe -q -s microcode > /dev/null 2> /dev/null || true
  54. fi
  55. DEV="xxx"
  56. if [ -e "$DEVICE" ]; then 
  57.     DEV="$DEVICE"
  58. elif [ -e "$DEVICE2" ]; then
  59.     DEV="$DEVICE2"
  60. elif [ -e "$DEVICE3" ]; then
  61.     DEV="$DEVICE3"
  62. else
  63. ## udev is slow creating devices, so in this case we wait
  64. ## some extra time (max 80 times 0.1s = 8s).
  65.     for i in `seq 80`; do
  66.     if [ -e "$DEVICE" ]; then 
  67.         DEV="$DEVICE"
  68.         break
  69.     fi
  70.     echo -n "."
  71.     sleep 0.1
  72.     done
  73.     if [ "$DEV" = "xxx" ]; then
  74.     echo "$0: microcode device $DEVICE doesn't exist!"
  75.     exit 0
  76.     fi
  77. fi
  78.  
  79.  
  80. echo -n "Applying Intel IA32 Microcode update... "
  81.  
  82. /usr/sbin/microcode_ctl -Q -d "$DEV" -f "$MICROCODE"
  83.  
  84. if [ $? -eq 0 ] ; then
  85.     echo "done."
  86. else
  87.     echo "fail."
  88. fi
  89.  
  90. # *try* to unload the microcode module
  91. #[ -x /sbin/modprobe ] && /sbin/modprobe -r microcode > /dev/null 2> /dev/null
  92.  
  93. }
  94.  
  95.  
  96. case "$1" in
  97.   start|""|reload|force-reload|restart)
  98.     doit
  99.     exit 0
  100.     ;;
  101.   stop)
  102.     ;;
  103.   *)
  104.     echo "$0 usage: microcode {start|restart|reload}"
  105.     exit 2
  106. esac
  107.  
  108.